<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        try {
            console.log('1');
            window.a();
            console.log('2');
        }
        catch (error) {
            console.log("发生了异常");
            console.log(error.name);  //错误类型
            console.log(error.stack);  //堆栈信息
            console.log(error.message);  //错误消息
            
        } finally {
            console.log("执行完成了");
        }

    </script>
</body>

</html>